/**
 * Created by Ysssssss on 21/1/27.
 */
import React  from 'react'
import { withRouter} from 'react-router-dom'
import { LeftOutlined } from "@ant-design/icons";

const PageBackHeader = props => {
    const {
        title,
        backUrl,
        backHidden,
        rightCustomizeInfo,
        history,
        beforeGoBack
    } = props

    const _goBack = () => {
        if (beforeGoBack) {
            beforeGoBack(() => {
                history.goBack(backUrl || -1)
            })
        } else {
            history.goBack(backUrl || -1)
        }
    }

    return (
        <div className="bilin-web-back-header">
            { backHidden ? (
                <div className="back-button pdl-16">
                    <span className="ft-16 ft-w500">{ title }</span>
                </div>
            ) : (
                <div className="back-button pdl-16" onClick={_goBack}>
                    <LeftOutlined className="mgr-12"/>
                    <span className="ft-16 ft-w500">{ title }</span>
                </div>
            ) }
            { rightCustomizeInfo || null }
        </div>
    )
}
export default withRouter(PageBackHeader)